package com.icinfo.cloud.provider.punish.service.impl;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.icinfo.cloud.provider.common.utils.HeaderUtil;
import com.icinfo.cloud.provider.punish.external.dto.CheckIdentityDto;
import com.icinfo.cloud.provider.punish.service.ExternalService;
import com.icinfo.framework.common.web.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
@Slf4j
public class ExternalServiceImpl implements ExternalService {
    @Value("${tzService.url}")
    private String url;

    /**
     * 姓名身份证核验
     * @author liyafeng
     * @date 2023/3/21
      * @param dto
     * @return {@link Result< String>}
     */
    @Override
    public Result<String> checkIdentity(CheckIdentityDto dto) {
        Map<String, String> headers = HeaderUtil.headerInfo();
        String param = JSON.toJSONString(dto);
        String response = HttpUtil.createPost(url.concat("external/nation/population/checkIdentity")).addHeaders(headers).body(param).execute().body();
        Result result = JSON.parseObject(response, Result.class);
        return result;
    }
}
